<?php

class Common_InputDialog extends GtkDialog
{
    function __construct($args)
    {
        parent::__construct($args["title"], null, Gtk::DIALOG_MODAL);
        $this->add_button(Gtk::STOCK_OK, 1);
        $this->add_button(Gtk::STOCK_CANCEL, 2);
                    
        /* Creating and adding a question to the dialog */
        $topArea = $this->vbox;
                
        $dialogQues = new GtkLabel($args["message"]);
        $topArea->pack_start($dialogQues);
        
        $hbox = new GtkHBox();
        $topArea->pack_start($hbox);
        
        $label = new GtkLabel($args["label"]);
        $hbox->pack_start($label);
        
        $this->entry = new GtkEntry();
        $hbox->pack_start($this->entry);
    }
    
    function getResponse()
    {
        /* Showing all widgets added */
        $this->show_all();

        /* Running the dialog box */
        $result = $this->run();

        /* Accessing the result and performing
           appropriate action */
        switch($result) {
            case (1):
                $answer = $this->entry->get_text();
                break;
                
            case (2);
                $answer = NULL;
                break;
        }
        
        /* Destroying the dialog box */
        $this->destroy();
        return($answer);
        
    }
}

